package com.android.supermarket.activity

import android.os.Bundle
import android.text.InputType
import android.util.Log
import android.view.Gravity
import android.view.ViewGroup
import com.android.supermarket.BaseActivity
import org.jetbrains.anko.*
import org.jetbrains.anko.design.textInputEditText
import org.jetbrains.anko.design.textInputLayout

/**
 * Created by pengtaoH on 2018/7/19.
 */
class LoginActivity : BaseActivity() {


    companion object {
        val user_name = 1
        var user_pwd = 2
        val login_id = 3
    }

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)

        verticalLayout {
            gravity = Gravity.CENTER
            textInputLayout {
                textInputEditText {
                    id = user_name
                    hint = "用户名"

                }.lparams(width = matchParent, height = wrapContent)
            }.lparams(width = matchParent, height = wrapContent) {
                setMargins(20, 10, 20, 10)
            }

            textInputLayout {
                textInputEditText {
                    id = user_pwd
                    hint = "密  码"
                    inputType = InputType.TYPE_NUMBER_VARIATION_PASSWORD
                }.lparams(width = matchParent, height = wrapContent)
            }.lparams(width = matchParent, height = wrapContent) {
                setMargins(20, 10, 20, 10)
            }

            Log.d("anko screen width : ", (resources.displayMetrics.widthPixels * 3 / 5).toString() + "-------- \n->" + dip(resources.displayMetrics.widthPixels * 3 / 5))
            button("登录") {
                id = login_id
            }.lparams(width = resources.displayMetrics.widthPixels * 2 / 3, height = wrapContent) {
                setMargins(20, 10, 20, 10)
            }
        }
    }

}
